﻿using System;
using System.Threading.Tasks;
using SilverCrmSoap.CrmSdk;


namespace Linq2Crm.Request.SpecificRequest
{
	public sealed class OrganizationRequestWrapper: RequestBase
	{
		private OrganizationRequestWrapper():base(null)
		{			
		}

		public OrganizationRequest OrganizationRequest { get; private set; }

		public Action<OrganizationResponseWrapper> Callback { get; set; }

		#region Overrides of RequestBase
		internal override void Execute()
		{
			DomainObjectContext.Instance.ExecuteOrganizationRequest(this);
		}

		internal override async Task<ResponseBase> ExecuteAsync()
		{
			var response = await DomainObjectContext.Instance.ExecuteOrganizationRequestAsync(this);
			return response;
		}

		#endregion

		public static OrganizationRequestWrapper Create(OrganizationRequest crmRequest)
		{

			return new OrganizationRequestWrapper()
			       	{
			       		OrganizationRequest = crmRequest
			       	};
		}
	}
}